package com.icngor.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.icngor.action.RepairAction;
import com.icngor.service.RepairServiceI;
import com.icngor.service.impl.UserServiceImpl;

public class RepairListener implements ServletContextListener {

	private static final Logger logger = Logger.getLogger(RepairListener.class);
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void contextInitialized(ServletContextEvent env) {
		logger.info("数据库修复");
		WebApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(env.getServletContext());
		RepairServiceI rs = (RepairServiceI) ac.getBean("repairService");
		rs.repair();
	}

}
